home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio
/
Ham Radio CD-ROM (Emerald Software) (1995).ISO
/
ant
/
antenna2
/
cheby.bas
< prev
next >
Wrap
BASIC Source File
|
1986-08-12
|
4KB
|
138 lines
10 ' chebychev synthesis
20 ' ahmad faizal mohd zain
30 ' 7/30/86
40 CLS:KEY OFF
50 PRINT" CHEBYCHEV SYNTHESIS":PRINT:PRINT
60 DIM A(100),F(200),Y(200)
70 DIM B(100),W(100),ANG(100)
80 DEF FN ARCOSH(X)=LOG(X+SQR(X*X-1))
90 DEF FN LOGTEN(X)=LOG(X)/LOG(10)
100 PI=3.141592
110 INPUT "Number of elements ";NE
120 IF NE MOD 2 =1 THEN M=(NE-1)/2 ELSE M=NE/2
130 INPUT"Element spacing ";D
140 INPUT"Side-lobe-level (in dB) ";RR
150 R=10^(-RR/20)
160 X=(1/(NE-1))*FN ARCOSH(R)
170 X0=(EXP(X)+EXP(-X))/2
180 X=(1/(NE-1))*FN ARCOSH(R/1.414)
190 X=(1/X0)*(EXP(X)+EXP(-X))/2
200 X=1.570796-ATN(X/SQR(1-X*X))
210 X=X/(PI*D)
220 HP=2*ATN(X/SQR(1-X*X))
230 PRINT:PRINT
240 PRINT USING"half power beamwidth is ##.##";HP*180/PI;:PRINT" deg."
250 IF NE MOD 2=1 THEN 600
260 FOR N=1 TO M
270 SUM=0
280 FOR Q=N TO M
290 X=Q+M-2:GOSUB 970:A=XX
300 X=Q-N:GOSUB 970:B=XX
310 X=Q+N-1:GOSUB 970:C=XX
320 X=M-Q:GOSUB 970:DD=XX
330 E=(-1)^(M-Q)
340 F=(X0)^(2*Q-1)
350 SUM=SUM+E*F*A*(2*M-1)/(B*C*DD)
360 NEXT Q
370 A(N)=SUM
380 NEXT N
390 PRINT:PRINT"The current elements (normalised) are :-"
400 FOR N=1 TO M
410 A(N)=A(N)/A(M)
420 PRINT "I(";N;") = ";:PRINT USING "##.####";A(N)
430 NEXT N
440 K=0
450 FOR U=-1 TO 1 STEP 1/100
460 SUM=0
470 FOR N=1 TO M
480 SUM=SUM+A(N)*COS((2*N-1)*PI*D*U)
490 NEXT N
500 F=ABS(2*SUM)
510 Y(K)=20*FN LOGTEN(F)
520 IF Y(K)>YMAX THEN YMAX=Y(K)
530 K=K+1
540 NEXT U
550 YMIN=2*RR+YMAX
560 GOSUB 1170:GOSUB 1250
570 GOSUB 1030
580 GOSUB 1410
590 END
600 FOR N=1 TO M+1
610 SUM=0
620 FOR Q=N TO M+1
630 X=Q+M-2:GOSUB 970:A=XX
640 X=Q-N:GOSUB 970:B=XX
650 X=Q+N-2:GOSUB 970:C=XX
660 X=M-Q+1:GOSUB 970:DD=XX
670 E=(-1)^(M-Q+1)
680 F=(X0)^(2*(Q-1))
690 EPSI=2
700 SUM=SUM+E*F*A*2*M/(EPSI*B*C*DD)
710 NEXT Q
720 A(N)=SUM
730 NEXT N
740 PRINT:PRINT"The current elements (normalised) are :-"
750 FOR N=1 TO M+1
760 B(N)=A(N)
770 A(N)=A(N)/A(M+1)
780 PRINT "I(";N;") = ";:PRINT USING "##.####";A(N)
790 NEXT N
800 K=0
810 FOR U=-1 TO 1 STEP 1/100
820 SUM=0
830 FOR N=1 TO M
840 SUM=SUM+A(N+1)*COS(2*N*PI*D*U)
850 NEXT N
860 SUM=2*SUM+A(1)
870 F=ABS(SUM)
880 Y(K)=20*FN LOGTEN(F)
890 IF Y(K)>YMAX THEN YMAX=Y(K)
900 K=K+1
910 NEXT U
920 YMIN=2*RR+YMAX
930 GOSUB 1170:GOSUB 1250
940 GOSUB 1030
950 GOSUB 1410
960 END
970 ' Subroutine to calculate factorials
980 XX=1
990 IF X=0 OR X=1 THEN RETURN
1000 XX=XX*X
1010 X=X-1
1020 GOTO 990
1030 LOCATE 1,10:PRINT"Number of elements are ";NE
1040 LOCATE 2,10:PRINT "element spacing is ";D;" lambda"
1050 RETURN
1160 RETURN
1170 LOCATE 25,1:PRINT "Type <return> to continue";:INPUT Q
1180 ' RECTANGULAR PLOT OF DATA
1190 SCREEN 2:CLS
1200 FOR K=7 TO 67 STEP 10:LOCATE 20,K:PRINT"+";:NEXT K
1210 FOR K=4 TO 20 STEP 4:LOCATE K,67:PRINT"-":NEXT K
1220 VIEW (52,28)-(530,154),,1
1230 LINE (239,0)-(239,154)
1240 RETURN
1250 '
1260 PSET (0,Y(0))
1270 WINDOW (-1,YMIN)-(1,YMAX)
1280 K=0
1290 FOR X=-1 TO 1 STEP 1/100
1300 LINE -(X,Y(K))
1310 K=K+1
1320 NEXT X
1330 LOCATE 3,20:PRINT"MAGNITUDE OF SYNTHESISED PATTERN"
1340 LOCATE 4,75:PRINT"dB"
1350 FOR K=4 TO 20 STEP 4:LOCATE K,68:PRINT USING "###.##";-(YMAX-YMIN)*(K-4)/16:NEXT K
1360 LOCATE 21,6:PRINT"180":LOCATE 21,36:PRINT"90":LOCATE 21,67:PRINT"0"
1370 RETURN
1380 LOCATE 24,1:PRINT"TYPE <RETURN> TO CONTINUE...";:INPUT W:SCREEN 0,0
1390 PRINT"I'M D OME CALCULATION. PLEASE WAIT..."
1400 RETURN
1410 T$="DO YOU WANT TO RUN THIS PROGRAM AGAIN (Y/N)? ":LC=23:GOSUB 1470
1420 AN$=INKEY$
1430 IF AN$="Y" OR AN$="y" THEN RUN
1440 IF AN$="N" OR AN$="n" THEN END
1450 GOTO 1410
1460 :
1470 LOCATE LC,(80-LEN(T$))/2+1:PRINT T$:RETURN 'SUBROUTINE TO CENTRE TEXT